﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SharpDX
{
    public class CCamera
    {
        public float posX;
        public float posY;
        public float posZ;

        public float rotX;
        public float rotY; 
        public float rotZ;

        public Matrix viewMat;

        public CCamera()
        {

        }
        public void setPos(float x,float y,float z)
        {
            posX = x;
            posY = y;
            posZ = z;
        }
        public void setRot(float x,float y ,float z)
        {
            rotX = x;
            rotY = y;
            rotZ = z;
        }
        public Vector3 getPos()
        {
            return new Vector3(posX, posY, posZ);
        }
        public Vector3 getRot()
        {
            return new Vector3(rotX, rotY, rotZ);
        }
        public void Render()
        {
            var pos = new Vector3(posX, posY, posZ);

            var lookAt = new Vector3(0, 0, 1);

            var pitch = rotX * 0.0174532925f;
            var yaw = rotY * 0.0174532925f;
            var roll = rotZ * 0.0174532925f;

            var rotMat = Matrix.RotationYawPitchRoll(yaw, pitch, roll);

            lookAt = Vector3.TransformCoordinate(lookAt, rotMat);

            var up = Vector3.TransformCoordinate(Vector3.UnitY, rotMat);

            lookAt = pos + lookAt;

            viewMat = Matrix.LookAtLH(pos, lookAt, up);

        }

    }
}
